package com.hg.chapter3.condition;

import com.hg.chapter3.condition.condition.MacCondition;
import com.hg.chapter3.condition.condition.WindowsCondition;
import com.hg.chapter3.condition.service.OsService;
import com.hg.chapter3.condition.service.impl.MacServiceImpl;
import com.hg.chapter3.condition.service.impl.WindowsServiceImpl;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Conditional;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.bind.annotation.RestController;

@Configuration
public class ConditionConfig {

    @Bean
    @Conditional(WindowsCondition.class)
    public OsService windows(){
        return new WindowsServiceImpl();
    }

    @Bean
    @Conditional(MacCondition.class)
    public OsService mac(){
        return new MacServiceImpl();
    }
}
